package com.central.product.controller

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.central.common.model.CommonResult
import com.central.common.model.PageVo
import com.central.product.pojo.drawProductGroup.*
import com.central.product.service.DrawProductGroupService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @author  fly
 * @date  2021/5/28 15:17
 * @version 1.0
 */
@Api(tags = ["(管理系统) 盒蛋组api"])
@RestController
@RequestMapping("/back/drawProductGroup")
open class BackDrawProductGroupController {


    @Autowired
    private lateinit var drawProductGroupService: DrawProductGroupService


    @ApiOperation("保存抽奖组")
    @PostMapping("/saveDrawProductGroup")
    fun saveDrawProductGroup(productDto: DrawProductDto): CommonResult<Any> =
        drawProductGroupService.saveDrawProductGroup(productDto)


    @ApiOperation("移除抽奖组")
    @PostMapping("/removeDrawProductGroup")
    fun removeDrawProductGroup(ids: String): CommonResult<Boolean> =
        drawProductGroupService.removeDrawProductGroup(ids)


    @ApiOperation("修改抽奖组")
    @PostMapping("/updateDrawProductGroup")
    fun updateDrawProductGroup(productDto: DrawProductDto): CommonResult<Any> =
        drawProductGroupService.updateDrawProductGroup(productDto)


    @ApiOperation("获取抽奖组列表")
    @GetMapping("/getDrawProductList")
    fun getDrawProductList(productGroupSearchDto: DrawProductGroupSearchDto, pageVo: PageVo): CommonResult<Page<DrawProductListVo>> =
        drawProductGroupService.getDrawProductList(productGroupSearchDto, pageVo)


    @ApiOperation("获取抽奖组详情信息")
    @GetMapping("/getDrawProductGroupDetail")
    fun getDrawProductGroupDetail(id: Long): CommonResult<DrawProductDetailVo> =
        drawProductGroupService.getDrawProductGroupDetail(id)


    @ApiOperation("抽奖一次获取的结果")
    @GetMapping("/getDrawResult")
    fun getDrawResult(drawProductGroupId: Long): CommonResult<DrawProductVo> =
        drawProductGroupService.getDrawResult(drawProductGroupId)
}
